#include <thread>
#include <iostream>
#include <vector>
#include <functional>
#include <atomic>
using namespace std;

void func(atomic<int>& counter)
{
    for (int i = 0;i < 100000;++i){
        counter.fetch_add(1);
    }
}

int main()
{
    atomic<int> counter(0);
    vector<thread> threads;
    for(int i = 0;i<10;++i){
        threads.push_back(thread{func,ref(counter)});
    }
    for(auto& t :threads){
            t.join();
    }
    cout << "Result = " << counter << endl;
    return 0;
}